package com.course.file.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
* springboot静态资源的配置，静态资源包含图片，css，js等
* */

/*
* 用@Conﬁguration注释类表明其主要目的是作为bean定义的源@Conﬁguration类允许通过调用同一类中的其他@Bean方法来定义bean之间的依赖关系
* */
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {
    @Value("${file.path}")
    private String FILE_PATH;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("/f/**").addResourceLocations("file:" + FILE_PATH);
    }
    // http://127.0.0.1:9003/file/f/teacher/423lEUk0-Snipaste_2020-07-27_10-45-14.jpg
}
